﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script type="text/javascript" src="/hui/lib/html5shiv.js"></script>
<script type="text/javascript" src="/hui/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/hui/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/hui/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/hui/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/hui/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/hui/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="/hui/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>待删除列表</title>
</head>
<body>
<nav class="breadcrumb"> <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<input type="text" class="input-text" style="width:250px" placeholder="用户名" id="search">
		<button type="submit" class="btn btn-success radius" id="sub"><i class="Hui-iconfont">&#xe665;</i> 精确查询</button>
	</div>

	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<input type="hidden" th:value="${currentPage}" id="currentPage">
		<input type="hidden" th:value="${total}" id="total">
		<div class="btn btn-default" onclick="pre()">上一页</div>
		<div class="btn btn-default" onclick="next()">下一页</div>
		<span class="r">共有数据：<strong th:text="${total}"></strong> 条</span>
	</div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-hover table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="60">ID</th>
					<th width="60">用户名</th>
					<th width="100">电话</th>
					<th width="140">邮箱</th>
					<th>描述</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
				<tr class="text-c" th:each="item:${pages}">
					<td th:text="${item.getUserId()}"></td>
					<td th:text="${item.getName()}"></td>
					<td th:text="${item.getTel()}"></td>
					<td th:text="${item.getEmail()}"></td>
					<td class="text-l" th:text="${item.getDescription()}"></td>
					<td class="td-manage">
						<a th:id="${item.getUserId()}" onclick="del(this.id)" title="删除" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/hui/lib/jquery/1.9.1/jquery.min.js"></script>
<script>
	var url="http://localhost:8080/sys-user/confirm?"
	function pre() {
		var currentPage=$("#currentPage").val();
		console.log(currentPage);
		if(currentPage>1){
			location=url+"currentPage="+(currentPage-1);
		}
	}

	function next() {
		var currentPage=$("#currentPage").val();
		var total=$("#total").val();
		console.log(currentPage);
		if(currentPage<(total/5.0)){
			location=url+"currentPage="+(currentPage-0+1);
		}
	}
	
	$("#sub").click(function () {
		location=url+"search="+$("#search").val()
	})

	function del(id) {
		var yes=confirm("确定要删除id为【"+id+"】的用户吗？");
		if(yes){
			$.ajax({
				url:"http://localhost:8080/sys-user/confirm",
				data:{
					userId:id
				},
				type:"POST",
				success:function (r) {
					if(r=="succeed"){
						alert("删除成功!")
					}else {
						alert("删除失败！")
					}
					location.reload();
				}
			})
		}
	}
</script>
</body>
</html>